#ifndef _CONFIG_FLASH_H_
#define _CONFIG_FLASH_H_

#include <stdint.h>
#include <stdbool.h>
#include <string.h>

#define FLASH_BASE_ADDR			0x08000000
#define FLASH_PAGE_SIZE		(1024*4)
#define FLASH_SIZE			0x00200000		//2MB

uint32_t flash_erase(uint32_t addr, uint32_t total);

void flash_read(uint32_t addr, uint8_t *bytes, uint16_t size);

void flash_read_with_icache(uint32_t addr, uint8_t *bytes, uint16_t size);

int flash_write(uint32_t addr, uint32_t *bytes, uint32_t size);

int flash_verify(uint32_t addr, void *bytes, uint32_t size);

int flash_write_data(uint32_t address, uint8_t data[], uint32_t length);

int flash_sync(void);

uint32_t flash_size(void);

void flash_flush_icache(void);

#endif

